<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .parent {
            width: 300px;
            /* height: 300px; */
            background-color: #ccc;
            /* 水平居中 */
            margin: 0 auto;
            display: flex;

        }

        .parent>div {
            width: 120px;
            height: 60px;
        }

        .parent>div:nth-child(2) {
            /* flex-shrink 父容器空间不足以放下所有弹性元素
            会进行等比例亚索 默认值为1
            flex-shrink为0时不进行压缩
            */
            flex-shrink:1 ;        
        }

    
    </style>
</head>

<body>
    <div class="parent">
        <div class="div1" style="background-color: rgb(223, 150, 234);">弹性元素1</div>
        <div class="div2" style="background-color: rgb(140, 186, 226);">弹性元素2</div>
        <div class="div3" style="background-color: rgb(239, 241, 143);">弹性元素3</div>
    </div>
</body>

</html>